//package com.zcf.controller;
//
//import java.io.IOException;
//import java.util.Date;
//
//import org.apache.http.client.HttpClient;
//import org.dom4j.Document;
//import org.dom4j.DocumentHelper;
//import org.dom4j.Element;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.*;
//
//import com.baomidou.mybatisplus.mapper.EntityWrapper;
//import com.zcf.common.json.Body;
//import com.zcf.pojo.ClubUser;
//import com.zcf.pojo.Proving;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpSession;
//
//@CrossOrigin
//@Controller
//@RequestMapping("/sends")
//public class SendSmsController {
//
//    private static String Url = "http://106.wx96.com/webservice/sms.php?method=Submit";
//    public static String code="";
//
//    @PostMapping("send")
//	@ResponseBody
//    public Body sendSms(HttpServletRequest request, HttpSession session, @RequestParam("phone") String phone) {
//        HttpClient client = new HttpClient();
//        PostMethod method = new PostMethod(Url);
//        System.out.println("手机号"+phone);
//
//        client.getParams().setContentCharset("GBK");
//        method.setRequestHeader("ContentType", "application/x-www-form-urlencoded;charset=GBK");
//
//        int mobile_code = (int) ((Math.random() * 9 + 1) * 100000);
//
//        String content = new String("您的验证码是：" + mobile_code + "。请不要把验证码泄露给其他人。");
//        System.out.println("您的验证码是：" + mobile_code + "。请不要把验证码泄露给其他人。");
//
//        NameValuePair[] data = {//提交短信
//                new NameValuePair("account", "C00261408"), //用户名请登录用户中心->验证码、通知短信->帐户及签名设置->APIID
//                new NameValuePair("password", "4914de1fb5b22e0168c933f08201fac6"),  //查看密码请登录用户中心->验证码、通知短信->帐户及签名设置->APIKEY
//                new NameValuePair("mobile", phone),
//                new NameValuePair("content", content),
//        };
//        method.setRequestBody(data);
//        try {
//            client.executeMethod(method);
//
//            String SubmitResult = method.getResponseBodyAsString();
//
//            System.out.println(SubmitResult);
//            
//            EntityWrapper<Proving> w = new EntityWrapper<Proving>();
//            w.eq("phone", phone);
//            Proving proving = new Proving();
//            Proving one = proving.selectOne(w);
//            if(one != null){
//            	one.setProving(String.valueOf(mobile_code));
//            	one.setCreateTime(new Date());
//            	one.updateById();
//            }else{
//            	proving.setPhone(phone);
//            	proving.setProving(String.valueOf(mobile_code));
//            	proving.setCreateTime(new Date());
//            	proving.insert();
//            }
//            
//            Document doc = DocumentHelper.parseText(SubmitResult);
//            Element root = doc.getRootElement();
//
//            String code = root.elementText("code");
//            String msg = root.elementText("msg");
//            String smsid = root.elementText("smsid");
//
//            System.out.println(code);
//            System.out.println(msg);
//            System.out.println(smsid);
//
//            if ("2".equals(code)) {
//                System.out.println("短信提交成功---验证码"+mobile_code);
//                request.getSession(true);
//                request.getSession().setAttribute("code", mobile_code);
//
//                return Body.newInstance(null);
//            }else{
//                return Body.newInstance(400,"未知错误请联系客服--同一验证码过多!");
//            }
//
//        } catch (IOException e) {
//            e.printStackTrace();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return Body.newInstance(400, "error");
//    }
//
//}